package com.dm.flyweight.demo02;

import java.util.HashMap;
import java.util.Map;

/**
 * 享元工厂
 * @author Administrator
 *
 */
public class FlyweightFactory {
	
	static Map<String,OwnCharacter> charMap = new HashMap<>();

	public static OwnCharacter createCharacter(String alph){
		//此处也可以初始化26个对象，返回不同的对象
		OwnCharacter character = charMap.get(alph);
		if(character==null){
			character = new OwnCharacter();
			character.alph = alph;
			charMap.put(alph, character);
		}
		return character;
	}

	public static OwnRow createRow(){
		return new OwnRow();
	}
	
	public static OwnColumn createColumn(){
		return new OwnColumn();
	}
	
}
